package com.stylefeng.guns.modular.customer.warpper;

import com.stylefeng.guns.core.base.warpper.BaseControllerWarpper;
import com.stylefeng.guns.core.common.constant.factory.ConstantFactory;
import com.stylefeng.guns.modular.customer.util.CustomerUtil;
import org.apache.commons.collections.MapUtils;

import java.util.Map;

public class CustomerCompanyManageWrapper extends BaseControllerWarpper {

    public CustomerCompanyManageWrapper(Object o) {
        super(o);
    }

    protected void warpTheMap(Map<String, Object> map) {
        Integer customerCompanyId = MapUtils.getInteger(map, "customerCompanyId");
        map.put("customerCompanyName",  ConstantFactory.me().getCustomerCompanyName(customerCompanyId));
        map.put("customerTypeName", ConstantFactory.me().getDictNameByNum("customer_type", MapUtils.getString(map, "customerTypeCode")));
        map.put("deptName", ConstantFactory.me().getDeptName((MapUtils.getInteger(map, "departId"))));
        map.put("salesmanName", ConstantFactory.me().getUserNameById((MapUtils.getInteger(map, "salesmanId"))));
        map.put("isCcbV", ConstantFactory.me().getDictNameByNum("yesOrNo", MapUtils.getString(map, "isCcb")));
        map.put("isPlanToOpenAccountV", ConstantFactory.me().getDictNameByNum("yesOrNo", MapUtils.getString(map, "isPlanToOpenAccount")));
        CustomerUtil.putAuthority(map,customerCompanyId);
    }
}
